<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin', function (Blueprint $table) {
            // 表引擎
            $table->engine = 'MyISAM';
            $table->charset = 'utf8';
            $table->collation = 'utf8_unicode_ci';
            $table->increments('id')->comment('编号id');
            $table->string('admin_name', 20)->unique()->comment('管理员账号');
            $table->string('admin_pwd', 60)->comment('管理员密码');
            $table->string('true_name', 20)->nullable()->comment('姓名');
            $table->string('phone', 20)->nullable()->comment('联系电话');
            $table->integer('create_time')->default(0)->comment('创建时间');
            $table->integer('role_id')->default(0)->comment('角色id');
            $table->string('login_ip', 40)->default(0)->comment('登录ip');
            $table->integer('login_time')->default(0)->comment('最后登录时间');
        });
        $db_prefix = env('DB_PREFIX');
        DB::statement("ALTER TABLE {$db_prefix}ladmin comment '管理员表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ladmin');
    }
}
